<template>
  <a-select ref="select" v-model:value="value1" style="width: 120px" @change="changeLanguage">
    <a-select-option value="zh-cn">中文</a-select-option>
    <a-select-option value="en">英文</a-select-option>
  </a-select>
  <div>{{ $t("common.more") }}</div>

  <hr />
  <a-button class="save btn" @click="onSuperComputSubmit">提交超算作业，动态获取超算提交作业表单</a-button>

  <!-- 超算动态表单 -->
  <XTModuleTableSuperComputerSubmit ref="refComputerSubmit" :form-data="formData" />

  <!-- 动态表格列 -->
  <hr />
  <a-button @click="onXTModuleTableColumn">动态表格列</a-button>
  <XTModuleTableColumn ref="refXTModuleTableColumn" />

  <!-- 团队管理 -->
  <hr />
  <div style="height: 100px"></div>
  <div style="padding: 40px">
    <XTModuleTeamManage />
  </div>

  <!-- 任务和项目选择资源 -->
  <hr />
  <div style="height: 100px"></div>
  <div style="padding: 40px">
    <XTModuleResources :tree-data="treeData2" :default-checked-keys="checkedKeys" :title="'分配设计资源'" />
  </div>
</template>

<script setup lang="ts">
import XTModuleTableSuperComputerSubmit from "@/components/Business/XTModuleTableSuperComputer/XTModuleTableSuperComputerSubmit.vue"
import XTModuleTableColumn from "@/components/Business/XTModuleTableColumn"
import XTModuleTeamManage from "@/components/Business/XTModuleTeamManage.vue"
import XTModuleResources from "@/components/Business/XTModuleResources.vue"

import { useI18n } from "vue-i18n"
import { shallowReadonly } from "vue"
const { locale } = useI18n()

const state = reactive({
  curLanguage: "zh-cn",
})

const checkedKeys = ref([])
const treeData2 = reactive([
  {
    name: "设计工具",
    id: "400",
    children: [{ id: "104", name: "欣欣2", parentId: "400" }],
  },

  {
    name: "超算",
    id: "200",
    children: [
      { id: "201", name: "王学理", parentId: "200" },
      { id: "202", name: "金华", parentId: "200" },
    ],
  },
])

setTimeout(() => {
  // checkedKeys.value = ["400"]
})

const value1 = ref<string>("zh-cn")

const changeLanguage = () => {
  state.curLanguage = state.curLanguage === "zh-cn" ? "en" : "zh-cn"
  locale.value = state.curLanguage
}

const refXTModuleTableColumn = shallowRef(null)
const onXTModuleTableColumn = () => {
  refXTModuleTableColumn.value.setOpen()
}

//动态获取超算表单
const refComputerSubmit = shallowRef(null)
let formData = shallowRef([])

const spinning = ref(false)

const onSuperComputSubmit = () => {
  spinning.value = true
  setTimeout(() => {
    formData.value = [
      { id: "1592457832882638848", key: "JH_JOB_NAME", label: "作业名称", rule: "^[A-Za-z0-9_]+$", type: "input", appId: "fluent", appType: "simu" },
      { id: "1592457832907804672", key: "JH_CAS", label: "CAS文件", rule: "^.*?\\.cas$", type: "file", appId: "fluent", appType: "simu" },
      { id: "1592457832928776192", key: "JH_DAT", label: "DAT文件", rule: "^.*?\\.dat$", type: "file", appId: "fluent", appType: "simu" },
      { id: "1592457832941359104", key: "JH_DUALTIMESTEP", label: "时间步长大小", rule: "^[0-9]+$", type: "input", appId: "fluent", appType: "simu" },
      { id: "1592457832941359105", key: "JH_TIMESTEP", label: "时间步数", rule: "^[0-9]+$", type: "input", appId: "fluent", appType: "simu" },
      { id: "1592457832945553408", key: "JH_ITERATION", label: "迭代步数", rule: "^[0-9]+$", type: "input", appId: "fluent", appType: "simu" },
      { id: "1592457832945553409", key: "JH_AUTOSAVE_FREQUENCY", label: "自动保存步数", rule: "^[0-9]+$", type: "input", appId: "fluent", appType: "simu" },
      { id: "1592457832945553410", key: "JH_NCPU", label: "CPU核数", rule: "^2$|^8$|^12$|^16$", type: "staticSelect", selectValue: "2|4|6|8", appId: "fluent", appType: "simu" },
      { id: "1592457832970719232", key: "JH_VERSION", label: "维数", rule: "^[2|3]d$", type: "staticSelect", selectValue: "2d|2ddp|3d|3ddp", appId: "fluent", appType: "simu" },
      { id: "1592457832974913536", key: "JH_RELEASE", label: "版本号", type: "staticSelect", isNecessary: 1, selectValue: "18.2|17.2|18.0", appId: "fluent", appType: "simu" },
      { id: "1592457832995885056", key: "JH_GUI_ENABLED", label: "图形界面支持", rule: "^on|^off$", type: "staticSelect", selectValue: "on|off", appId: "fluent", appType: "simu" },
    ]
    refComputerSubmit.value.setOpen()
  })
}
</script>
